$INCLUDE: 'C:\FG\FASTGRAF.FI'

      PROGRAM MAIN

      INTEGER*1 PIXEL_RUNS(20000)
      INTEGER FILE_SIZE, RUN_COUNT
      INTEGER OLD_MODE, NEW_MODE
      INTEGER FILELENGTH
      INTEGER FG_BESTMODE, FG_GETMODE

      CALL FG_INITPM
      NEW_MODE = FG_BESTMODE(320,200,1)
      IF (NEW_MODE .LT. 0 .OR. NEW_MODE .EQ. 12) THEN
         STOP 'This program requires a 320 x 200 color graphics mode.'
      END IF

      OLD_MODE = FG_GETMODE()
      CALL FG_SETMODE(NEW_MODE)

      OPEN(UNIT=1,STATUS='OLD',FILE='CORAL.SPR',FORM='BINARY',RECL=1)
      FILE_SIZE = FILELENGTH(1)
      READ(1) (PIXEL_RUNS(I),I=1,FILE_SIZE)
      CLOSE(UNIT=1)
      RUN_COUNT = FILE_SIZE / 2
      CALL FG_MOVE(0,199)
      CALL FG_DISPLAY(PIXEL_RUNS,RUN_COUNT,320)
      CALL FG_WAITKEY

      OPEN(UNIT=1,STATUS='OLD',FILE='CORAL.PPR',FORM='BINARY',RECL=1)
      FILE_SIZE = FILELENGTH(1)
      READ(1) (PIXEL_RUNS(I),I=1,FILE_SIZE)
      CLOSE(UNIT=1)
      RUN_COUNT = FILE_SIZE / 3 * 2
      CALL FG_ERASE
      CALL FG_DISPLAYP(PIXEL_RUNS,RUN_COUNT,320)
      CALL FG_WAITKEY

      CALL FG_SETMODE(OLD_MODE)
      CALL FG_RESET

      STOP ' '
      END

      INTEGER FUNCTION FILELENGTH(UNIT)
      INTEGER UNIT

      INTEGER*1 CH

      FILELENGTH = 0
10    READ(UNIT,END=99) CH
      FILELENGTH = FILELENGTH + 1
      GO TO 10

99    REWIND UNIT
      RETURN
      END
